;;c and cpp
;;;;
(add-hook 'c-mode-hook 'hs-minor-mode)
(add-hook 'c++-mode-hook 'hs-minor-mode)

;;;;C/C++
(add-hook 'c-mode-hook 'my-c-cpp-mode)
(add-hook 'c++-mode-hook 'my-c-cpp-mode)
(defun my-c-cpp-mode()
  ;; C-j
  (define-key c-mode-map [return] 'newline-and-indent)
  (interactive)
  (define-key c++-mode-map [return] 'newline-and-indent)
  (interactive)
  ;; 
  (c-set-style "K&R")
  ;;
  (which-function-mode)
  ;; {
;;;(c-toggle-auto-state);;
  ;; Backspace
  (c-toggle-hungry-state)
  ;; 4
  (setq c-basic-offset 2)
  ;;tab
  (setq-default indent-tabs-mode nil)
  ;;Alt+Return 
  ;(define-key c-mode-base-map [M-return] 'semantic-ia-complete-symbol-menu)
  (define-key c++-mode-map (kbd "<f1> 1") 'gtags-find-tag)
  (define-key c-mode-map (kbd "<f1> 1") 'gtags-find-tag)
  (define-key c++-mode-map (kbd "<f1> 2") 'gtags-find-rtag)
  (define-key c-mode-map (kbd "<f1> 2") 'gtags-find-rtag)
  )

(setq auto-mode-alist
      (cons '("\\.h$" . c++-mode)
	    auto-mode-alist))